﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Miris.HumanMilkAnalyser.DataModel;
using Miris.HumanMilkAnalyser.Service;
using Miris.HumanMilkAnalyser.Service.Shared;
using Miris.HumanMilkAnalyser.WPF.Model;

namespace Miris.HumanMilkAnalyser.WPF.ViewModel.TestItemViewModel
{
    public class TestItemCarbohydrateViewModel : TestItemSingleViewModel
    {
        /// <summary>
        /// Initializes a new instance of the CarbohydrateTestItemViewModel class.
        /// </summary>
        public TestItemCarbohydrateViewModel(IDataService dataService, IList<AnalysisItem> analysisItemList, MilkStage milkStage)
            : base(dataService, analysisItemList, milkStage) { }

        protected override void InitializeParameters()
        {
            base.InitializeParameters();

            TestItemName = AnalysisItemDefinition.CarbohydrateItemName;
            SetAnalysisItem();
        }

        /// <summary>
        /// Set RangeStartValue & RangeEndValue based on CurrentMilkStage.
        /// </summary>
        protected override void SetTestResultRangeValue()
        {
            if (CurrentMilkStage == MilkStage.Unmature)
            {
                //RangeStartValue = 1.1;
                //RangeEndValue = 7.9;

                RangeStartValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CarbohydrateUnmatureMilkRangeStartValue);
                RangeEndValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CarbohydrateUnmatureMilkRangeEndValue);
            }
            else if (CurrentMilkStage == MilkStage.Transitional)
            {
                //RangeStartValue = 6.1;
                //RangeEndValue = 6.7;

                RangeStartValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CarbohydrateTransitionalMilkRangeStartValue);
                RangeEndValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CarbohydrateTransitionalMilkRangeEndValue);
            }
            else if (CurrentMilkStage == MilkStage.Mature)
            {
                //RangeStartValue = 4.9;
                //RangeEndValue = 9.5;

                RangeStartValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CarbohydrateMatureMilkRangeStartValue);
                RangeEndValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CarbohydrateMatureMilkRangeEndValue);
            }
        }

        /// <summary>
        /// Set MinValue & MaxValue based on CurrentMilkStage.
        /// </summary>
        protected override void SetTestResultMinMaxValue()
        {
            base.SetTestResultMinMaxValue();

            //MaxValue = CurrentMilkStage == MilkStage.Mature ? 15 : 10;

            if (CurrentMilkStage == MilkStage.Unmature)
            {
                MaxValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CarbohydrateUnmatureMilkMaxValue);
            }
            else if (CurrentMilkStage == MilkStage.Transitional)
            {
                MaxValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CarbohydrateTransitionalMilkMaxValue);
            }
            else if (CurrentMilkStage == MilkStage.Mature)
            {
                MaxValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CarbohydrateMatureMilkMaxValue);
            }
        }
    }
}
